package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.Coursetalk;
import com.czh.springboot04.mapper.CoursetalkMapper;
import com.czh.springboot04.service.CoursetalkService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoursetalkServiceImpl implements CoursetalkService {
    @Autowired
    private CoursetalkMapper coursetalkMapper;
    @Override
    public int insert(Coursetalk coursetalk) {
        int i = coursetalkMapper.insert(coursetalk);
        return i;
    }

    @Override
    public int delete(int id) {
        int i = coursetalkMapper.delete(id);
        return i;
    }

    @Override
    public int update(Coursetalk coursetalk) {
        int i = coursetalkMapper.update(coursetalk);
        return i;
    }

    @Override
    public PageInfo<Coursetalk> select(int pageNum, int pageSize, String nickName, String courseName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Coursetalk> coursetalk = coursetalkMapper.select(nickName, courseName);
        PageInfo<Coursetalk> pageInfo = new PageInfo<>(coursetalk);
        return pageInfo;
    }
}
